package analysishandler

import (
	"github.com/gin-gonic/gin"
	"yundian/internel/app/dao"
	"yundian/internel/app/helper/request"
	"yundian/internel/app/models/statistics"
	"yundian/internel/pkg/dingo"
	. "yundian/internel/pkg/dingo/result"
)

// HandleGetStatisticsPlaceList 门店列表
func HandleGetStatisticsPlaceList(ctx *gin.Context) {
	param := &request.NoSettlementPlaceReq{}
	dingo.ErrorIf(ctx.ShouldBindJSON(param)).Unwrap()

	data := dao.NewStatisticsDao().FetchNoSettlementPlaceList(param)
	lists := data.Unwrap().([]*statistics.StatisticsUserList)

	// 分页信息
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       lists,
	})(OK)
}

// HandleGetNoSettlementPlaceList 无流水门店列表
func HandleGetNoSettlementPlaceList(ctx *gin.Context) {
	param := &request.NoSettlementPlaceReq{}
	dingo.ErrorIf(ctx.ShouldBindJSON(param)).Unwrap()

	data := dao.NewStatisticsDao().FetchNoSettlementPlaceList(param)
	lists := data.Unwrap().([]*statistics.StatisticsUserList)

	// 分页信息
	Response(ctx)("", CodeSuccess, ResponseList{
		PageNo:     param.PageNo,
		PageSize:   param.PageSize,
		TotalCount: data.Val().(int64),
		TotalPage:  (data.Val().(int64) + int64(param.PageSize) - 1) / int64(param.PageSize),
		Data:       lists,
	})(OK)
}
